<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$intID = (int)$_data["ID"];
//找出 Marquee  Site
$arrSite = $_arrMarqueeSite;//array();
/*$strSQL = "select ID, Sites_".$_intLang." as Sites from `bet_MarqueeSite` order by ID";
if(!$RS = PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Marquee Data Error!!";
	$GLOBALS["errorhidden"] = "\n<!-- Error: ".PMA_mysql_error($$_Conn).",\nLine: ".__LINE__.",\nPage: ".__FILE__." //-->";
	ErrMsgOutputHTML("Error", "", 1);
}
while($Rows = PMA_mysql_fetch_object($RS)){
	$arrSite[$Rows -> ID] = $Rows -> Sites;
}*/

//找出 走馬燈 訊息
$strSQL = "select * from `bet_Marquee` where ID = ".$intID;
if(!$RS = PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Marquee Data Error!!";
	$GLOBALS["errorhidden"] = "\n<!-- Error: ".PMA_mysql_error($$_Conn).",\nLine: ".__LINE__.",\nPage: ".__FILE__." //-->";
	ErrMsgOutputHTML("Error", "", 1);
}

if(PMA_mysql_num_rows($RS) == 0){
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List&Page=".(string)intval($_data["Page"]));
	exit();
}
$Rows = PMA_mysql_fetch_object($RS);


$fp = @file($strTemplatePath."Edit.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

$fp = str_replace("{intID}", $intID, $fp);
$fp = str_replace("{Page}", $_data["Page"], $fp);

if(!$isShowIsHidden)$fp = preg_replace("/<!-- BOF@isHidden \/\/-->.+<!-- EOF@isHidden \/\/-->/s", $strCon, $fp);

//$Rows -> Content_1 = addslashes($Rows -> Content_1);
//$Rows -> Content_2 = addslashes($Rows -> Content_2);
//$Rows -> Content_3 = addslashes($Rows -> Content_3);
$fp = str_replace("{ShowContent_1}", htmlspecialchars($Rows -> Content_1), $fp);
$fp = str_replace("{ShowContent_2}", htmlspecialchars($Rows -> Content_2), $fp);
$fp = str_replace("{ShowContent_3}", htmlspecialchars($Rows -> Content_3), $fp);

$fp = str_replace("{isSystemChecked".$Rows -> isSystem."}", "checked", $fp);
$fp = str_replace("{isPopupChecked".$Rows -> isPopup."}", "checked", $fp);
$fp = str_replace("{isOnlineChecked".$Rows -> isOnline."}", "checked", $fp);
$fp = str_replace("{isHiddenChecked".$Rows -> isHidden."}", "checked", $fp);
$fp = str_replace("{ShowOnDate}", $Rows -> OnDate, $fp);
$fp = str_replace("{ShowOffDate}", $Rows -> OffDate, $fp);

$intKey = 0;
$strCon = "";
$strTmp = "";

preg_match("/<!-- @ Site Start @ \/\/-->(.+)<!-- @ Site End @ \/\/-->/s", $fp, $arrCon);
//print $Rows -> Sites;
foreach($arrSite as $intSID => $strSite){
	$strTmp = $arrCon[1];
	$strCheck = (preg_match("/,".$intSID.",/", ",".$Rows -> Sites.","))?"checked":"";
	preg_match("/@".$intSID."=([^@]+)@/", "@".$Rows -> SpGroup."@", $arrKey);
	$strTmpSpgTag = getSpGroupTag($intSID, $arrKey[1]);
	if($strCheck != "")$strTmpSpgTag = str_replace("disabled", "", $strTmpSpgTag);

	$strTmp = str_replace("{ShowKey}", $intKey, $strTmp);
	$strTmp = str_replace("{ShowSiteID}", $intSID, $strTmp);
	$strTmp = str_replace("{ShowSiteName}", $strSite." ".$strTmpSpgTag, $strTmp);
	$strTmp = str_replace("{Checked}", $strCheck, $strTmp);
	$strCon .= $strTmp."\n";
	$intKey++;
}
$fp = preg_replace("/<!-- @ Site Start @ \/\/-->.+<!-- @ Site End @ \/\/-->/s", $strCon, $fp);

while(list($k, $v) = each($_strMarquee)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

//輸出
WebOutputHTML($fp, 1);
?>